package com.share.introspection;

import java.lang.module.Configuration;
import java.lang.module.ModuleFinder;
import java.nio.file.Paths;
import java.sql.Driver;
import java.util.Set;

/**
 * @author caifan
 * @created 2021/12/15
 * @description:
 */
public class BootLayer {
    public static void main(String[] args) {
        ModuleLayer.boot().modules().forEach(System.out::println);

        System.out.println("============");
        Driver driver = null; // We reference java.sql.Driver to see 'java.sql' gets resolved
        ModuleLayer.boot().modules().forEach(m -> System.out.println(m.getName() + ", loader: " + m.getClassLoader()));
        System.out.println("System classloader: " + ClassLoader.getSystemClassLoader());

//        ModuleFinder finder = ModuleFinder.of(Paths.get("./modules"));
//        ModuleLayer bootLayer = ModuleLayer.boot();
//        Configuration config = bootLayer.configuration()
//                .resolve(finder, ModuleFinder.of(), Set.of("rootmodule"));
//        ClassLoader scl = ClassLoader.getSystemClassLoader();
//        ModuleLayer newLayer = bootLayer.defineModulesWithOneLoader(config, scl);
    }
}
